<?php

$_CLASS['prossimoClienteCLS'] = "class_php/prossimoClienteCLS.php";

class console extends Module
{
	var $socket = 0;
	var $analyzeArray = 1;
	var $analyzeError = 1;
	var $connDB = 1;
	var $func = 1;
	var $funcDB = 0;
	var $sqlFunc = 1;
	var $request = array();
	var $smarty = 1;
	var $session = array();
	var $impBase = array();
	var $fldError = array();
	var $usrError = array();
	var $sysError = array();
	var $usrInfo = array();
	var $usrInfoFuncJS = '';
	var $usrInfoValueBtn = '';
	var $extClass = array();
	var $appLog = 1;
	var $lastPageNo = 0;
	var $menu = 1;
	var $security = 1;
	
	function start()
	{
		
		if ($this->request["saveConsole"] == 'S')
		{
			//effettuo il login alla console
			$idInterfaccia = $this->prossimoClienteCLS->interfaceAgentCheck("onLogin","SIP/{$this->session["operatore"]}|{$this->session["idCampagna"]}","0,1");
			if ($idInterfaccia == "") $this->prossimoClienteCLS->interfaceAgentInsert("onLogin","SIP/{$this->session["operatore"]}|{$this->session["idCampagna"]}",0);
			
			$this->session["loginConsole"] = 'S';

// 			exec()

		}
		elseif ($this->request["saveConsole"] == 'P')
		{
			//metto l'operatore in pausa
			/*$idInterfaccia = $this->prossimoClienteCLS->interfaceAgentCheck("onAgentStateChange","SIP/{$this->session["operatore"]}|3",'0,1');
			if ($idInterfaccia == "")*/ $this->prossimoClienteCLS->interfaceAgentInsert("onAgentStateChange","SIP/{$this->session["operatore"]}|3",0);
			
			$this->session["loginConsole"] = 'P';
		}
		elseif ($this->request["saveConsole"] == 'R')
		{
			//metto l'operatore in pronto
			/*$idInterfaccia = $this->prossimoClienteCLS->interfaceAgentCheck("onAgentStateChange","SIP/{$this->session["operatore"]}|4",'0,1');
			if ($idInterfaccia == "") */$this->prossimoClienteCLS->interfaceAgentInsert("onAgentStateChange","SIP/{$this->session["operatore"]}|4",0);
				
			$this->session["loginConsole"] = 'S';
			
		}
		elseif ($this->request["saveConsole"] == 'REC')
		{
			//metto l'operatore in pronto
			//0 = stop
			//1 = start
			//2 = pausa
			//3 = resume
			
			//POD_ggmmaaaa_hhmm_T036
// 			$recName = $this->session["chiamataId"]."_T036";
			$oraData = date('H');
			$timeData = date('i');
			$recName = $this->session["chiamataId"]."_".date('dmY_').$oraData.$timeData."_POD_T036";
// 			$idInterfaccia = $this->prossimoClienteCLS->interfaceAgentCheck("onAgentStateChange","SIP/{$this->session["operatore"]}|7",'0,1');
			/*if ($idInterfaccia == "")*/ $this->prossimoClienteCLS->interfaceAgentInsert("onAgentMonitor","SIP/{$this->session["operatore"]}|1|$recName",0);
				
			$this->session["statusCall"] = 'REC';
			
		}
		elseif ($this->request["saveConsole"] == 'STOP')
		{
			//metto l'operatore in pronto
// 			$idInterfaccia = $this->prossimoClienteCLS->interfaceAgentCheck("onAgentStateChange","SIP/{$this->session["operatore"]}|4",'0,1');
			/*if ($idInterfaccia == "") */ $this->prossimoClienteCLS->interfaceAgentInsert("onAgentMonitor","SIP/{$this->session["operatore"]}|0",0);
				
			$this->session["statusCall"] = 'STOP';
			
		}
		elseif ($this->request["saveConsole"] == 'HANGUP')
		{
			//attacco la chiamata
			$this->prossimoClienteCLS->interfaceAgentInsert("onAgentHangup","SIP/{$this->session["operatore"]}",0);
				
			$this->session["statusCall"] = 'HANGUP';
			
		}
		elseif ($this->request["saveConsole"] == 'ENDCALL')
		{
			//attacco le chiamate e chiudo il wraptime
			$this->prossimoClienteCLS->interfaceAgentInsert("onAgentHangup","SIP/{$this->session["operatore"]}",0);
// 			$this->prossimoClienteCLS->interfaceAgentInsert("onAgentStateChange","SIP/{$this->session["operatore"]}|13",0);
				
// 			$this->session["loginConsole"] = 'S';
			
		}
		elseif ($this->request["saveConsole"] == 'AZZERA')
		{
			//attacco le chiamate e chiudo il wraptime
// 			$this->prossimoClienteCLS->interfaceAgentInsert("onAgentHangup","SIP/{$this->session["operatore"]}",0);
			$this->prossimoClienteCLS->interfaceAgentInsert("onAgentStateChange","SIP/{$this->session["operatore"]}|13",0);
				
// 			$this->session["loginConsole"] = 'S';
			
		}

// 		print "|{$this->session["statusCall"]}|";
// 		print_r($this->session);
// 		print_r($this->request);
		$this->session["idStatoOperatore"] = $idInterfaccia;
		$this->fillValue("loginConsole|statusCall", $this->session);
		$this->fillValue("saveConsole|recordingConsole", $this->request);
		//print  $this->request["typeList"];
	}

	function show()
	{		
//$this->smarty->assign("ajax","yes");
		
			$this->smarty->assign("mod","campagne");
			$this->smarty->assign("do","console");
			$this->smarty->assign("page","console");

			$this->smarty->display($this->session["ruolo"]."/campagne/console.tpl.html");
		
	}
}

?> 
 
 
